package com.coda.app.controller;

import com.coda.app.service.ViewAppointmentService;
import com.coda.appVo.appointment.AppointmentDetailVo;
import com.coda.appVo.appointment.AppointmentItemVo;
import com.coda.entity.ViewAppointment;
import com.coda.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/app/appointment")
@Api(tags = "看房预约")
public class ViewAppointmentController {

    @Autowired
    private ViewAppointmentService viewAppointmentService;
    /**
     * 保存或更新看房预约
     */
    @PostMapping("/saveOrUpdate")
    @ApiOperation("保存或更新看房预约")
    public Result saveOrUpdate(@RequestBody ViewAppointment viewAppointment){
        viewAppointmentService.saveOrUpdate(viewAppointment);
        return Result.ok();
    }

    /**
     * 查询个人预约看房列表
     */
    @GetMapping("/listItem")
    @ApiOperation("查询个人预约看房列表")
    public Result<List<AppointmentItemVo>> getList(){
        List<AppointmentItemVo> appointmentItemVoList = viewAppointmentService.getList();
        return Result.ok(appointmentItemVoList);
    }
    /**
     * 根据id查询预约详情信息
     */
    @GetMapping("getDetailById")
    @ApiOperation("根据id查询预约详细信息")
    public Result<AppointmentDetailVo> getDetailById(@RequestParam Long id){
        AppointmentDetailVo appointmentDetailVo = viewAppointmentService.getDetailById(id);
        return Result.ok(appointmentDetailVo);
    }
}
